import {default as api} from "../../utils/request";
import cookie from "js-cookie";

const COOKIE_KEY="we_ucenter"
const user = {
  state: {
    loginInfo: {}
  },
  mutations: {
    SET_LOGIN_INFO: (state, loginInfo) => {
      cookie.set(COOKIE_KEY,loginInfo)
      state.loginInfo = loginInfo
    },
  }, actions: {
    // 获取信息
    setUserInfo({commit, state}) {
      commit('SET_LOGIN_INFO',state);
    },
    logOut() {
      cookie.set(COOKIE_KEY, {})
    },
    reloadUser({commit, state},userInfo){
      cookie.set(COOKIE_KEY, userInfo)
    }
  }
}
export default user
